/**
 * @brief LCD driver header
 * @author Gilad Avidov
 */
#ifndef LCD_H_INCLUDED
#define LCD_H_INCLUDED

#define LCD_MAX_X           (15)
#define LCD_MAX_Y           (3)
#define LCD_CHAR_ROWS       (8)
#define LCD_CHAR_COLS       (5)
#define LCD_CHAR_CUSTOM_CNT (8)

// Name: lcdinit()
// Description: Initializes the LCD (see Figure 25 on page 212
// of the HD44780U data sheet).
void lcdinit();

// Name: lcdbusywait()
// Description: Polls the LCD busy flag. Function does not return
// until the LCD controller is ready to accept an other command.
void lcdbusywait();

// Name: lcdgotoaddr()
// Description: Sets the cursor to the specified LCD DDRAM address.
// Should call lcdbusywait().
void lcdgotoaddr(unsigned char addr);

// Name: lcdgotoxy()
// Description: Sets the cursor to the LCD DDRAM address corresponding
// to the specified row and column. Location (0,0) is the top left
// corner of the LCD screen. Must call lcdgotoaddr().
void lcdgotoxy(unsigned char row, unsigned char column);

// Name: lcdputch()
// Description:Writes the specified character to the current
// LCD cursor position. Should call lcdbusywait().
void lcdputch(char cc);

// Name: lcdputstr()
// Description: Writes the specified null-terminated string to the LCD
// starting at the current LCD curs or position. Automatically wraps
// long strings to the next LCD line after the right edge of the
// display screen has been reached. Must call lcdputch().
void lcdputstr(char *ss);

// Name: lcdcreatechar()
// Description: Function to create a 5x8 pixel custom character with
// character code ccode (0<=ccode<=7) using the row values given in
// the 8-byte array row_vals[].
void lcdcreatechar(unsigned char ccode, unsigned char row_vals[]);

// all_row_vals array of LCD_CHAR_CUSTOM_CNT row_vals
// each row_val is LCD_CHAR_ROWS size array
void lcdcreate_all_chars(unsigned char all_row_vals[LCD_CHAR_CUSTOM_CNT][LCD_CHAR_ROWS]);

void lcd_read_screen(xdata char *buf, int buf_len);

#endif // LCD_H_INCLUDED
